#ifndef	_MM_H
#define	_MM_H

// #define KERNEL_START 0xffff000000000000

#include "asm/base.h"
#include "type.h"
#include "mmu.h"

#define LOW_MEMORY              	(2 * SECTION_SIZE)

#ifndef __ASSEMBLER__

#define VirtToPhy(x)            (x - KERNEL_START)
#define PhyToVirt(x)            (x + KERNEL_START)

typedef struct {
	u32   flag;
	void*  p_addr;
	u32   count;
} Page;

typedef struct {
	u64*   bitmap_p;
	u64    bitmap_size;
	u64    bitmap_num;

	Page*  pages_p;
	u64    pages_size;
	u64    pages_num;

	void*  end_addr;
} MemoryManagement;


void memzero(unsigned long src, unsigned long n);
void memory_init();
void* alloc_one_page();
void free_one_page(void* addr);
void* kmalloc(u64 size);
void kfree(void* addr);

extern char text_begin[];
extern char text_end[];
extern char rodata_begin[];
extern char rodata_end[];
extern char data_begin[];
extern char data_end[];
extern char bss_begin[];
extern char bss_end[];

#endif

#endif  /*_MM_H */
